package my.springboot.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Aspect
@Component
public class AopAdvice {
	
	@Pointcut("@annotation(my.springboot.aop.ResultLog)")
	void resultLog(){};
	
	public void before(JoinPoint point){
		
	}
	
	@AfterReturning(value = "resultLog()",returning = "result")
	public void afterResult(JoinPoint point,Object result){
		String methodName = point.getSignature().getName();
		Object[] args = point.getArgs();
    	log.debug("【aop】【{}】params:{}\tresult:{}",methodName,args,result);
	}
	
	public void after(){
		
	}
	
	public void around(){
		
	}
	
	public void afterThrowing(){
		
	}
	
}
